﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using FluentNHibernate.Mapping;
using Entities;

namespace Mapping
{
    public class AllocationMap : ClassMap<Allocation>
    {
        public AllocationMap()
        {
            Id(x => x.Id).GeneratedBy.Identity();

            Map(x => x.FactorForControl)
                .Not.Nullable();
            Map(x => x.FactorForConsultation);
            Map(x => x.RatingFactor);
            Map(x => x.FactorForBeforeExam);
            Map(x => x.CountingFactor);
            HasManyToMany(x => x.StudyPlanItems)
                .ParentKeyColumn("AllocationId")
                .ChildKeyColumn("StudyPlanItemId")
                .Cascade.SaveUpdate()
                .Table("SPItemAllocation");
            HasMany(x => x.LoadAtoms)
                .Cascade.All()
                .KeyColumn("AllocationId")
                .Inverse();
        }
    }
}
